
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use std.textio.all;

entity rom is
    Port ( ADDR : in  STD_LOGIC_VECTOR (9 downto 0);
           DOUT : out  STD_LOGIC_VECTOR (17 downto 0));
			  
end rom;

architecture Behavioral of rom is
type ROMTABLE is array (0 to 1023) of std_logic_vector (0 downto 17);
	impure function leer_fichero_rom (fichero : in string) return ROMTABLE is                                                                  
       variable linea : line;                                 
       variable rom_instrucciones       : ROMTABLE;    
		 --type char_file is file of character;
         FILE c_file_handle         : text is in fichero;       
        --variable C: std_ulogic;
		  variable I: integer := 0;		 
    begin            

        --file_open(c_file_handle, "rom.txt", READ_MODE);
        while not endfile(c_file_handle) loop
            readline (c_file_handle, linea);                             
            read (linea,rom_instrucciones(I));
				I<=I+1;
        end loop;
        file_close(c_file_handle);
		  return rom_instrucciones;
   end function;

	 
  variable rom_instrucciones       : ROMTABLE;   
	  
begin
      
		rom_instrucciones=leer_fichero_rom("rom.txt");
end process;
end Behavioral;

